#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
typedef long long LL;
const int maxn=100005;
bool use[maxn];
int ancestor[maxn],Q[maxn],a[maxn];
pair<int,int>ask[maxn];
vector<pair<int,int> >v[maxn],w[maxn];//second=id
/////////////////LCA off line////////////////////
void init_lca(int n){
	for(int i=0;i<n;i++)v[i].clear(),w[i].clear(),use[i]=0;
	}
inline void make_set(int x){a[x]=x;}
int find(int x){
    if(a[x]!=x)a[x]=find(a[x]);
    return a[x];
    }       
inline void merge(int u,int v){u=find(u);v=find(v);a[v]=u;} 
void LCA_OFF(int x,int pr){
	make_set(x);ancestor[x]=x;
	for(vector<pair<int,int> >::iterator it=v[x].begin();it!=v[x].end();++it)if(it->first!=pr){
		LCA_OFF(it->first,x);merge(x,it->first);ancestor[find(it->first)]=x;
		}
	use[x]=1;
	for(vector<pair<int,int> >::iterator it=w[x].begin();it!=w[x].end();++it)if(use[it->first]){
		Q[it->second]=ancestor[find(it->first)];
		}
	}
/////////////////LCA off line////////////////////
int ans[maxn],pre[maxn],dp[maxn];
void dfs(int x,int pr){
	for(vector<pair<int,int> >::iterator it=v[x].begin();it!=v[x].end();++it)if(it->first!=pr){
		dfs(it->first,x);
		pre[it->first]=it->second;
		ans[x]+=ans[it->first];
		}
	}
int main(){
	int n,m,x,y;
	while(scanf("%d",&n)!=EOF){
		for(int i=0;i<n;i++)v[i].clear(),w[i].clear(),use[i]=0;
		for(int i=1;i<n;i++){
			scanf("%d%d",&x,&y);x--;y--;
			v[x].push_back(make_pair(y,i));v[y].push_back(make_pair(x,i));
			}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%d%d",&x,&y);x--;y--;
			ask[i]=make_pair(x,y);
			w[x].push_back(make_pair(y,i));w[y].push_back(make_pair(x,i));
			}
		LCA_OFF(0,0);
		for(int i=0;i<n;i++)ans[i]=0;
		for(int i=0;i<m;i++)ans[ask[i].first]++,ans[ask[i].second]++,ans[Q[i]]-=2;
		
		dfs(0,0);
		for(int i=1;i<n;i++)dp[pre[i]]=ans[i];
		for(int i=1;i<n;i++)printf("%d ",dp[i]);
		puts("");
		}
    return 0;
    }
/*
5
1 2
1 3
2 4
2 5
2
1 4
3 5

5
3 4
4 5
1 4
2 4
3
2 3
1 3
3 5
*/
